package sao.testes;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Time;
import java.text.DateFormat;
import java.util.Calendar;

import sao.bd.BD;

public class TiposDadosBanco {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			BD bd = new BD();
			String sql = "SELECT * FROM Disponibilidade";
			ResultSet rs = bd.executarStatement(sql);
			rs.next();
			Time inicioHorario1 = rs.getTime("inicio_horario1");
			System.out.println("incioHorario1 = " + inicioHorario1);
			bd.fechar();
			
			Calendar cal = Calendar.getInstance();
			DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
			DateFormat df2 = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
			cal.setTime(inicioHorario1);
			System.out.println("df.format(cal.getTime()): " + df.format(cal.getTime()));
			System.out.println("df2.format(cal.getTime()): " + df2.format(cal.getTime()));
			
			// Somar 30 minutos
			System.out.println("Vamos somar 30 minutos...");
			cal.add(Calendar.MINUTE, 30);
			System.out.println("df.format(cal.getTime()): " + df.format(cal.getTime()));
			System.out.println("df2.format(cal.getTime()): " + df2.format(cal.getTime()));
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
